<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-28 10:05:05
 * @LastEditors: Please set LastEditors
 * @Description: 允许访问ip
 * @FilePath: /special/application/adminapiv3/controller/platform_manage/ServerAllowIpController.php
 */

namespace app\adminapiv3\controller\platform_manage;

//ip白名单
use app\adminapiv3\controller\BaseController;
use think\Request;

class ServerAllowIpController extends BaseController
{
    /**
     * @name 列表
     * @author wx
     * @date 2019/10/28 10:26
     */
    public function list(Request $request)
    {
        //接收参数
        $params = $request->only([
            'ip','login_time'
        ],'get');

        $server = new \app\adminapiv3\service\platform_manage\ServerAllowIpService();
        $list = $server->list($params);

        return $this->jsonOutPut($list);
    }

    /**
     * @name 添加
     * @author wx
     * @date 2019/10/28 10:26
     */
    public function add(Request $request)
    {
        $params = $request->only(['ip'],'post');

        $this->validate($params,'ServerAllowIp.add');

        $server = new \app\adminapiv3\service\platform_manage\ServerAllowIpService();
        $server->add($params);
        return $this->jsonOutPut();
    }

    /**
     * @name 编辑
     * @author wx
     * @date 2019/10/28 10:27
     */
    public function modify(Request $request)
    {
        //接收参数
        $params = $request->only([
            'id','ip'
        ],'post');

        $this->validate($params,'ServerAllowIp.modify');
        $server = new \app\adminapiv3\service\platform_manage\ServerAllowIpService();
        $server->modify($params['id'],$params);
        return $this->jsonOutPut();
    }

    /**
     * @name 删除
     * @author wx
     * @date time
     */
    public function del(Request $request)
    {
        //接收参数
        $params = $request->only(['id'],'post');

        $this->validate($params,'ServerAllowIp.del');
        $server = new \app\adminapiv3\service\platform_manage\ServerAllowIpService();
        $server->del($params['id']);

        return $this->jsonOutPut();
    }

}